package com.qububu.play.dineTogether.dto;

import java.util.Arrays;

import com.qububu.utils.SystemUtil;

public class ActionFoodDto {

	private StapleFood stapleFood;
	
	private String foodId;
	private String foodName;
	private String foodPic;
	private String actionId;
	
	
	public String getFoodId() {
		return foodId;
	}
	
	public String getFoodName() {
		return foodName;
	}
	public void setFoodName(String foodName) {
		this.foodName = foodName;
	}
	public String getFoodPic() {
		return foodPic;
	}
	public void setFoodPic(String foodPic) {
		this.foodPic = foodPic;
	}
	public String getActionId() {
		return actionId;
	}
	
	
	public StapleFood getStapleFood() {
		return stapleFood;
	}
	public void setStapleFood(StapleFood stapleFood) {
		this.stapleFood = stapleFood;
	}

	/**
	 * @功能 id加密
	 */
	public ActionFoodDto(String foodId, String actionId){
		this.foodId = foodId;
		this.actionId = actionId;
	}
	
	public ActionFoodDto(long foodId, long actionId){
		this.foodId = SystemUtil.encrypt(String.valueOf(foodId) );
		this.actionId = SystemUtil.encrypt(String.valueOf(actionId) );
	}

	/**
	 * @功能 是否是主菜判断
	 * @author 
	 *
	 */
	public enum StapleFood {
		ISSTAPLE(1),
		NOSTAPLE(0);
		
		private int intValue;
		
		private StapleFood(int intValue) {
			this.intValue = intValue;
		}
		
		/**
		 * 根据传入字符串来返回对应的状态类型
		 */
		public static StapleFood getStapleFood(String strValue) {
			try {
				StapleFood type = valueOf(strValue);
				return type;
			}
			catch(Exception ex) {
				throw new IllegalArgumentException("Value '" + strValue + "' is not allowed in StapleFood. Only "
						+ Arrays.toString(StapleFood.values()) + " are allowed."
						);
			}
		}
		
		public static StapleFood getStapleFood(int intValue) {
			for (StapleFood elem : StapleFood.values()) {
				if (elem.toIntValue() == intValue) {
					return elem;
				}
			}

			throw new IllegalArgumentException("Value '" + intValue
					+ "' is not allowed in StapleFood.");
		}
		
		/**
		 * 返回int值类型。
		 * @return
		 */
		public int toIntValue() {
			return intValue;
		}
	}
}
